import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkAnimalGamePage(Base):
    """
    车乐汇猜动物游戏页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 关闭按钮
        self.animal_close_btn = (By.XPATH, Carpark.RESOURCE_ID_Animal.format("btn_exit"))

        # 猜歌名标题提示
        self.animal_title_text = (By.XPATH, Carpark.RESOURCE_ID_Animal.format("tv_question"))

        # 答案1
        self.animal_answer_one_text = (By.XPATH, Carpark.animal_answer.format(""))

        # 答案2
        self.animal_answer_two_text = (By.XPATH, Carpark.animal_answer.format(""))

        # 答案3
        self.animal_answer_three_text = (By.XPATH, Carpark.animal_answer.format(""))

        # 答案4
        self.animal_answer_four_text = (By.XPATH, Carpark.animal_answer.format(""))

        # 第几题
        self.animal_questions_text = (By.XPATH, Carpark.RESOURCE_ID_Animal.format("tv_label_question_num"))

        # 动物图片
        self.animal_picture_icon = (By.XPATH, Carpark.RESOURCE_ID_Animal.format("iv_right"))

    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.animal_close_btn)

    def get_title(self):
        """
        获取回答题目标题

        :return:获取元素
        """
        return self.find_element_o(self.animal_title_text)

    def get_questions(self):
        """
        获取第几题文本

        :return:获取元素
        """
        return self.find_element_o(self.animal_questions_text)

    def click_answer_one(self, index=1):
        """
         点击答案1按钮

         :return:None
         """
        self.animal_answer_one_text = (By.XPATH, Carpark.animal_answer.format(index))
        self.click_element(self.animal_answer_one_text)

    def click_answer_two(self, index=2):
        """
         点击答案2按钮

         :return:None
         """
        self.animal_answer_two_text = (By.XPATH, Carpark.animal_answer.format(index))
        self.click_element(self.animal_answer_two_text)

    def click_answer_three(self, index=3):
        """
         点击答案3按钮

         :return:None
         """
        self.animal_answer_three_text = (By.XPATH, Carpark.animal_answer.format(index))
        self.click_element(self.animal_answer_three_text)

    def click_answer_four(self, index=4):
        """
         点击答案4按钮

         :return:None
         """
        self.animal_answer_four_text = (By.XPATH, Carpark.animal_answer.format(index))
        self.click_element(self.animal_answer_four_text)

    def get_picture(self):
        """
        获取动物图片

        :return:获取元素
        """
        return self.find_element_o(self.animal_picture_icon)

    def is_display_carpark_game(self):
        """
        查看是否进入猜动物回答中页面

        :return:
        """
        return self.is_display(self.animal_picture_icon)
